/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package com.sun.Facade;

import com.sun.Entity.Truck;
import java.util.List;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.PersistenceContext;

/**
 *
 * @author Trasheur
 */
@Stateless
public class TruckFacade implements TruckFacadeLocal {
    @PersistenceContext
    private EntityManager em;

    public void create(Truck truck) {
        em.persist(truck);
    }

    public void edit(Truck truck) {
        em.merge(truck);
    }

    public void remove(Truck truck) {
        em.remove(em.merge(truck));
    }

    public Truck find(Object id) {
        return em.find(Truck.class, id);
    }

    public List<Truck> findAll() {
        return em.createQuery("select object(o) from Truck as o").getResultList();
    }

}
